(define (sort/predicate pred loi)
    (sort-aux pred `() loi)
)

(define (sort-aux pred l loi)
    (if (null? loi) 
        l
        (sort-aux pred (set-aux pred l (car loi)) (cdr loi))
    )
)

(define (set-aux pred loi i)
    (cond 
        ((null? loi) 
            (list i)
        )
        ((pred (car loi) i)
            (cons (car loi) (set-aux (cdr loi) i))
        )
        (else
            (cons i loi)
        )
    )
)

(display
    (sort > `(8 2 5 2 3))
)

(display
    (sort < `(8 2 5 2 3))
)
